package com.acme.bankapp.domain.bank;

public class CheckingAccount extends AbstractAccount{
	private int overdraft;
	
	public CheckingAccount(int initialValue, int overdraft) {
		super(initialValue);
		this.overdraft = overdraft;
	}

	public void withdraw(int sum){
		assert (this.getBalance() >=0 && overdraft >=0);
		if(sum > this.getBalance()&& sum <= this.getBalance() + overdraft){
			overdraft = this.getBalance() + overdraft - sum;
			this.setBalance(0);
		}
		else if(sum <= this.getBalance()){
			setBalance(this.getBalance() - sum);
		}
		else{
			System.out.println("You cannot get this sum");
		}

	}
	
	public int getOverdraft(){
		return overdraft;
	}
	
	public int maximumAmountToWithdraw(){
		return this.getBalance() + overdraft;
	}
	
	public static void main(String[] args){
		CheckingAccount ch = new CheckingAccount(150,10);
		ch.withdraw(1200);
	}
}
